#![no_std]
#![no_main]

mod bsp;

extern crate alloc;

use alloc::{collections::BTreeMap, vec};

use seminix::{
    entry::main_entry,
    irq::irqchip_name,
    println,
    processor::cpu_relax,
    sched::current::current,
    space::{addr::mem_dump, kalloc::kalloc_dump},
    utils::percpu::PercpuData,
};

#[main_entry]
fn main() -> ! {
    mem_dump();
    kalloc_dump();

    println!("{}", irqchip_name());

    let mut v = vec![2, 5];
    v.push(4);
    v.push(6);
    println!("{:?}, cap {}", v, v.capacity());

    test();

    println!("current task: {}", current().name());

    let mut percpu = PercpuData::new();
    percpu.init_perdata(3);

    let data = percpu.get(7);
    println!("data {}", data);

    loop {
        cpu_relax();
    }
}

fn test() {
    let mut rbtree = BTreeMap::new();

    rbtree.insert(2, 4);
    rbtree.insert(1, 4);
    rbtree.insert(24, 4);
    rbtree.insert(21, 4);
    rbtree.insert(25, 4);
    rbtree.insert(26, 4);

    println!("{:?}", rbtree);
}
